/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package entities;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author selam
 */
@Entity
@Table(name = "generalpackage")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Generalpackage.findAll", query = "SELECT g FROM Generalpackage g"),
    @NamedQuery(name = "Generalpackage.findByGPackageId", query = "SELECT g FROM Generalpackage g WHERE g.gPackageId = :gPackageId"),
    @NamedQuery(name = "Generalpackage.findByPrice", query = "SELECT g FROM Generalpackage g WHERE g.price = :price"),
    @NamedQuery(name = "Generalpackage.findByDateCreated", query = "SELECT g FROM Generalpackage g WHERE g.dateCreated = :dateCreated")})
public class Generalpackage implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "GPackageId")
    private Integer gPackageId;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "Price")
    private Float price;
    @Column(name = "DateCreated")
    @Temporal(TemporalType.DATE)
    private Date dateCreated;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "gPackageId")
    private Collection<Personalpackage> personalpackageCollection;
    @JoinColumn(name = "User_Id", referencedColumnName = "User_Id")
    @ManyToOne(optional = false)
    private User userId;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "gPackageId")
    private Collection<Productcontainment> productcontainmentCollection;

    public Generalpackage() {
    }

    public Generalpackage(Integer gPackageId) {
        this.gPackageId = gPackageId;
    }

    public Integer getGPackageId() {
        return gPackageId;
    }

    public void setGPackageId(Integer gPackageId) {
        this.gPackageId = gPackageId;
    }

    public Float getPrice() {
        return price;
    }

    public void setPrice(Float price) {
        this.price = price;
    }

    public Date getDateCreated() {
        return dateCreated;
    }

    public void setDateCreated(Date dateCreated) {
        this.dateCreated = dateCreated;
    }

    @XmlTransient
    public Collection<Personalpackage> getPersonalpackageCollection() {
        return personalpackageCollection;
    }

    public void setPersonalpackageCollection(Collection<Personalpackage> personalpackageCollection) {
        this.personalpackageCollection = personalpackageCollection;
    }

    public User getUserId() {
        return userId;
    }

    public void setUserId(User userId) {
        this.userId = userId;
    }

    @XmlTransient
    public Collection<Productcontainment> getProductcontainmentCollection() {
        return productcontainmentCollection;
    }

    public void setProductcontainmentCollection(Collection<Productcontainment> productcontainmentCollection) {
        this.productcontainmentCollection = productcontainmentCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (gPackageId != null ? gPackageId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Generalpackage)) {
            return false;
        }
        Generalpackage other = (Generalpackage) object;
        if ((this.gPackageId == null && other.gPackageId != null) || (this.gPackageId != null && !this.gPackageId.equals(other.gPackageId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.Generalpackage[ gPackageId=" + gPackageId + " ]";
    }
    
}
